﻿using System;

namespace diantou.web.user
{
    /// <summary>
    /// 用户关系
    /// </summary>
    [fastCSharp.code.cSharp.webView.clientType(Name = "diantou.userRelation")]
    struct userRelation
    {
        /// <summary>
        /// 用户
        /// </summary>
        public diantou.dataAccess.user User;
        /// <summary>
        /// 用户
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        public int Id
        {
            get { return User == null ? 0 : User.Id; }
        }
        /// <summary>
        /// 当前用户
        /// </summary>
        public int UserId;
        /// <summary>
        /// 是否举报过用户
        /// </summary>
        public bool IsReport
        {
            get
            {
                return UserId != 0 && diantou.dataAccess.tcpCall.reportUser.isReport(UserId, User.Id);
            }
        }
        /// <summary>
        /// 是否已经加入黑名单
        /// </summary>
        public bool IsBlacklist
        {
            get
            {
                return UserId != 0 && diantou.dataAccess.tcpCall.focusUser.IsFocus(UserId, User.Id, dataModel.focus.type.Blacklist);
            }
        }
        /// <summary>
        /// 参与话题数量
        /// </summary>
        public int JoinTopicCount
        {
            get
            {
                return diantou.dataAccess.tcpCall.topic.getUserJoinCount(Id, UserId);
            }
        }
        /// <summary>
        /// 关系位图
        /// </summary>
        public int RelationMap
        {
            get
            {
                if (Id == 0) return -1;
                return diantou.dataAccess.tcpCall.user.GetRelationMap(User.Id, UserId);
            }
        }
        /// <summary>
        /// 收藏夹数量
        /// </summary>
        public int FavoriteCount
        {
            get
            {
                if (Id == 0) return 0;
                return diantou.dataAccess.tcpCall.favorite.getUserCount(User.Id, UserId);
            }
        }
    }
}
